package sso.resource.utils;

import com.fasterxml.jackson.databind.ObjectMapper;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;

public class WebUtils{
    public static void writeJsonToClient(HttpServletResponse response,
                                         Map<String,Object> map) throws IOException {
        response.setCharacterEncoding("utf-8");
        response.setContentType("application/json;charset=utf-8");
        PrintWriter out = response.getWriter();
        String result = new ObjectMapper().writeValueAsString(map);
        out.println(result);
        out.flush();
    }
}
